<template>
  <div class="data-app-detail-page">
    <div class="header bg f-c">
      <div class="nav-box f-s">
        <div class="header-content">
          <Navbar />
        </div>
      </div>
    </div>
    <div class="header2 f-r">
      <div class="product-img" />
      <div class="product-detail f-c j-b">
        <div class="product-name">{{ detail.name }}</div>
        <div class="product-sub">
          <div>服务厂商：{{ detail.serviceProviderName }}</div>
          <div>分类：{{ }}</div>
        </div>
        <div class="product-star f-r a-e">
          <el-rate v-model="detail.evaluateScore" disabled />
          <span>{{ detail.evaluateScore }}分  ( {{ detail.evaluateCount }}次评分 )</span>
        </div>
        <div>
          <el-button type="primary" @click="toSubscribe">订阅</el-button>
          <el-button v-show="tabName === '2'" @click="toEvaluation">评价</el-button>
        </div>
      </div>
    </div>
    <div class="body">
      <el-tabs v-model="tabName">
        <el-tab-pane name="1" label="服务详情">
          <div v-html="detail.detail" />
        </el-tab-pane>
        <el-tab-pane name="2" label="服务评价">
          <el-card v-for="item in scoreList" :key="item.id" shadow="none">
            <el-form label-position="top" disabled>
              <el-form-item label="综合得分：">
                <el-rate v-model="item.score" />
              </el-form-item>
              <el-form-item
                v-for="(qItem,qindex) in item.scoreItem"
                :key="qindex"
                :label="`${qindex + 1}、${qItem.question}`"
              >
                <el-rate v-model="qItem.score" />
                <el-input resize="none" type="textarea" />
              </el-form-item>
            </el-form>
          </el-card>
          <el-card v-for="(item,index) in scoreList" :key="index" shadow="none">
            <el-form label-position="top" disabled>
              <el-row>
                <el-col :span="7">
                  <div class="userinfo-box f-r a-c">
                    <el-avatar :src="item.avatar" :size="70" />
                    <div class="userinfo f-c j-b">
                      <div class="username">{{ item.createName }}</div>
                      <div class="username">{{ item.createDeptName }}</div>
                    </div>
                  </div>
                </el-col>
                <el-col :span="2"> <div class="line" /></el-col>
                <el-col :span="15">
                  <el-form-item label="综合得分：">
                    <el-rate v-model="item.score" disabled style="margin-bottom: 0" />
                  </el-form-item>
                </el-col>
              </el-row>
              <el-form-item
                v-for="(qItem,qindex) in item.scoreItem"
                :key="qindex"
                :label="`${qindex + 1}、${qItem.question}`"
              >
                <el-rate v-model="qItem.score" />
                <el-input resize="none" type="textarea" />
              </el-form-item>
            </el-form>
          </el-card>
          <div class="tips" @click="getPage">{{ isEnd ? '到底了' : '点击更多' }}</div>
        </el-tab-pane>
      </el-tabs>
    </div>
    <div class="footer">
      <div class="db-container">
        <div class="footer-item">
          <div class="footer-text">主板：xxx市政务服务数据管理局</div>
          <div class="footer-text">技术支持单位：xxx市大数据资源管理中心</div>
          <div class="footer-text">运营：xxx市XXXX科技发展集团有限公司</div>
        </div>
        <div class="footer-item" style="justify-content: center">
          <div class="footer-text">粵ICP备10001213213号码-7</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import Navbar from '../layout/navbar'
import { http_shop_tool } from '@/api'

export default {
  name: 'Index',
  components: {
    Navbar
  },
  data() {
    return {
      detail: {
      },
      tabName: '1',
      ruleForm: {
        star: 4,
        star1: 3,
        star1Text: '',
        star2: 3,
        star2Text: '',
        userList: [
          { username: '李小燕',
            dep: '教育局-管理员',
            avatar: '',
            star: 4,
            star1: 3,
            star1Text: '',
            star2: 3,
            star2Text: ''
          },
          { username: '李小燕',
            dep: '教育局-管理员',
            avatar: '',
            star: 4,
            star1: 3,
            star1Text: '',
            star2: 3,
            star2Text: ''
          }
        ]
      },
      scoreList: [],
      pageNo: 0,
      pageSize: 10,
      total: 0,
      isEnd: false
    }
  },
  created() {
    const id = this.$route.params.id
    http_shop_tool.read({ id }).then(res => {
      this.detail = res
    })
    this.getPage()
  },
  methods: {
    getPage() {
      if (this.pageNo === 0 || (this.pageNo * this.pageSize < this.total)) {
        this.pageNo++
        http_shop_tool.applicationPage({
          pageNum: this.pageNo,
          pageSize: this.pageSize,
          order: 'id',
          orderAsc: false,
          businessType: 'application',
          businessId: this.$route.params.id
        }).then(res => {
          this.total = res.total
          this.scoreList = res.list
          if (res.total <= this.pageSize) {
            this.isEnd = true
          }
        })
      } else {
        this.isEnd = true
        this.$message.warning('到底了')
      }
    },
    toSubscribe(item) {
      this.$router.push({
        path: '/shop-tool-subscribe/' + this.$route.params.id
      })
    },
    toEvaluation() {
      // this.$router.push({
      //   path: '/shop-app-evaluation'
      // })
    }
  }
}
</script>

<style lang="scss">
.data-app-detail-page {
  background-color: #F3F5F9;
  .tips {
    font-size: 24px;
    text-align: center;
    line-height: 60px;
    cursor: pointer;
  }
  .header2 {
    width: 1400px;
    margin: 0 auto;
    padding: 50px 0;
    .product-img {
      width: 330px;
      height: 348px;
      background: linear-gradient(180deg, #DBE9FF, #FFFFFF);
      box-shadow: 0px 0px 10px 0px rgba(114,127,148,0.3);
      border-radius: 5px;
      margin-right: 60px;
    }
    .product-detail {
      padding: 29px 0;
      .product-name {
        font-size: 30px;
        font-family: Microsoft YaHei;
        font-weight: bold;
        color: #322F2F;
      }
      .product-sub {
        font-size: 18px;
        font-family: Microsoft YaHei;
        font-weight: 400;
        color: #322F2F;
        line-height: 35px;
      }
      .product-star {
        font-size: 18px;
        font-family: Microsoft YaHei;
        font-weight: 400;
        color: #3D72FF;
        .el-rate {
          height: initial;
        }
        .el-rate__icon {
          font-size: 36px;
        }
      }
    }
  }
  .body {
    width: 1400px;
    margin: 0 auto;
    .el-card {
      margin-bottom: 30px;
    }
    .userinfo-box {
      position: relative;
      .userinfo {
        padding: 8px 0 ;
        margin-left: 20px;
        font-size: 18px;
        font-family: Microsoft YaHei;
        font-weight: 400;
        color: #333333;
        line-height: 36px;
      }
      &::after {
        height: 72px;
        width: 2px;
        background-color: #ECF0F8;
        display: inline-block;
        content: " ";
        position: absolute;
        right: 20px;
        top: 50%;
        transform: translateY(-50%);
      }

    }
    .el-rate {
      height: initial;
      margin-bottom: 20px;

    }
    .el-rate__icon {
      font-size: 36px;
    }
    .el-textarea__inner {
      width: 1000px;
      height: 70px;
      background: #ECF0F8;
      border-radius: 5px;
    }
  }
  .footer {
    width: 100%;
    background: #e6ecf5;
    height: 100px;
    padding: 23px;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    .footer-item {
      width: 730px;
      height: 30px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      text-align: center;
      .footer-text {
        font-size: 12px;
        color: #7a7a7a;
      }
    }
  }
  .header {
    width: 100%;
    background-image: url("~@/assets/shop/head.jpg");
  }
  .nav-box {
    border-bottom: 2px solid rgba(255, 255, 255, 0.4);
  }
  .header-content {
    width: 1400px;
    margin: 0 auto;
    padding: 20px 0;
  }
  .nav-box2 {
    width: 1400px;
    height: 350px;
    margin: 0 auto;
    .el-input,
    .el-button {
      height: 60px;
      .el-input__inner {
        height: 60px;
        line-height: 60px;
      }
    }
    .title {
      font-size: 48px;
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: #fff;
      margin-bottom: 34px;
      font-style: oblique;
    }
    .record-list {
      height: 19px;
      cursor: pointer;
      font-size: 18px;
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: #ffffff;
      margin-bottom: 21px;
      span {
        position: relative;
        padding-right: 40px;
      }
      span::after {
        position: absolute;
        content: " ";
        height: 16px;
        width: 1px;
        top: 50%;
        transform: translateY(-50%);
        right: 0;
        margin: 0 15px;
        background-color: #ffffff;
      }
      span:last-child:after {
        display: none;
      }
    }
    .el-input-group__append,
    .el-button {
      color: #ffffff !important;
      background-color: #0052d9 !important;
      border-color: #0052d9 !important;
    }
  }
  .count-box {
    margin:0 auto;
    width: 750px;
    .count-item {
      .count {
        font-size: 36px;
        color: #fff;
        line-height: 36px;
        text-align: center;
      }
      .count-name {
        color: #cfd6e6;
        font-size: 18px;
        margin-top: 18px;
        text-align: center;
      }
    }
  }
}
</style>
